package com.ruoyi.system.interfacechannel.controller;


import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.interfacechannel.domain.InterfacePush;
import com.ruoyi.system.interfacechannel.service.IInterfacePushService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

/**
 * 接口推送表(interface_push)表控制层
 *
 * @author zyy
 * @date 2024-01-22 14:10:01
 */
@RestController
@RequestMapping("/interfacePush")
public class InterfacePushController extends BaseController {
    /**
     * 服务对象
     */
    @Autowired
    private IInterfacePushService interfacePushService;

    /**
     * 分页查询所有数据
     *
     * @param interfacePush 查询实体
     * @return 所有数据
     */
    @GetMapping("/list")
    public TableDataInfo list(InterfacePush interfacePush) {
        startPage();
        List<InterfacePush> list = interfacePushService.list();
        return getDataTable(list);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(interfacePushService.getById(id));
    }

    /**
     * 新增数据
     *
     * @param interfacePush 实体对象
     * @return 新增结果
     */
    @Log(title = "InterfacePush", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult insert(@RequestBody InterfacePush interfacePush) {
        return toAjax(interfacePushService.save(interfacePush));
    }

    /**
     * 修改数据
     *
     * @param interfacePush 实体对象
     * @return 修改结果
     */
    @Log(title = "InterfacePush", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult update(@RequestBody InterfacePush interfacePush) {
        return toAjax(interfacePushService.updateById(interfacePush));
    }

    /**
     * 删除数据
     *
     * @param ids 主键结合
     * @return 删除结果
     */
    @Log(title = "InterfacePush", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(interfacePushService.removeByIds(Arrays.asList(ids)));
    }
}

